using UnityEngine;
using System.Collections;

public class GameCamera : MonoBehaviour 
{
	public Vector3 _initPos;
    protected Transform _playerTM;
    protected Camera _mainCamera;

    public float LerpSpeed;

    void Start()
    {
        _playerTM = GameObject.FindWithTag("Player").transform;
        _mainCamera = Camera.mainCamera;
    }
	
	public void Reset()
	{
		transform.localPosition = _initPos;	
	}

    void LateUpdate()
    {
        if (_playerTM == null)
            return;

        if (_playerTM.localPosition.y > (_mainCamera.transform.localPosition.y ))
        {
            float delta = _mainCamera.transform.localPosition.y;
            delta = Mathf.Lerp(delta, _playerTM.localPosition.y, LerpSpeed);

            _mainCamera.transform.localPosition = new Vector3(0, delta , 0);
        }
    }
}
